import { createApp } from 'vue'
import { createPinia } from 'pinia'
import Antd from 'ant-design-vue'
import App from './App.vue'
import router from './router'
import 'ant-design-vue/dist/reset.css'

// 创建Pinia实例
const pinia = createPinia()

// 创建Vue应用实例
const app = createApp(App)

// 全局配置Ant Design Vue
app.use(Antd)
app.use(pinia)
// 使用路由和状态管理
app.use(router)

// 初始化用户状态
import { useUserStore } from '@/stores/user'
const userStore = useUserStore()
if (localStorage.getItem('token')) {
  userStore.fetchUserStats()
}

// 挂载应用
app.mount('#app')
